-- ----------------------------
-- Table structure for agriculture_baseinfo
-- ----------------------------
DROP TABLE IF EXISTS agriculture_baseinfo;

CREATE TABLE agriculture_baseinfo
(
    base_id         BIGINT        NOT NULL DEFAULT nextval('agriculture_baseinfo_base_id_seq'::regclass),
    base_short_name VARCHAR(20)   NOT NULL DEFAULT '',
    base_code       VARCHAR(20)   NOT NULL DEFAULT '',
    base_name       VARCHAR(30)   NOT NULL DEFAULT '',
    base_leader     VARCHAR(10)   NOT NULL DEFAULT '',
    leader_tel      VARCHAR(17)   NOT NULL DEFAULT '',
    base_address    VARCHAR(500)  NOT NULL DEFAULT '',
    base_area       VARCHAR(30)   NOT NULL DEFAULT '',
    base_altitude   INTEGER       NOT NULL DEFAULT 0,
    base_img        VARCHAR(500)  NOT NULL DEFAULT '',
    base_des        VARCHAR(1000) NOT NULL DEFAULT '',
    remark          VARCHAR(2000) NOT NULL DEFAULT '',
    status          CHAR(1)       NOT NULL DEFAULT '0',
    order_num       INTEGER       NOT NULL DEFAULT 0,
    create_by       BIGINT        NOT NULL DEFAULT 0,
    create_time     TIMESTAMP     NULL,
    update_by       BIGINT                 DEFAULT 0,
    update_time     TIMESTAMP     NULL,
    del_flag        CHAR(1)       NOT NULL DEFAULT '0',
    base_coordinate VARCHAR(255)  NOT NULL DEFAULT '',
    create_dept        int8,
    tenant_id       BIGINT        NOT NULL DEFAULT 0,
    PRIMARY KEY (base_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_baseinfo_base_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_baseinfo IS '基地信息表';
COMMENT ON COLUMN agriculture_baseinfo.base_id IS '基地ID';
COMMENT ON COLUMN agriculture_baseinfo.base_short_name IS '基地简称';
COMMENT ON COLUMN agriculture_baseinfo.base_code IS '基地编号';
COMMENT ON COLUMN agriculture_baseinfo.base_name IS '基地全称';
COMMENT ON COLUMN agriculture_baseinfo.base_leader IS '基地负责人';
COMMENT ON COLUMN agriculture_baseinfo.leader_tel IS '基地负责人电话';
COMMENT ON COLUMN agriculture_baseinfo.base_address IS '基地负责人地址';
COMMENT ON COLUMN agriculture_baseinfo.base_area IS '基地面积';
COMMENT ON COLUMN agriculture_baseinfo.base_altitude IS '基地海拔';
COMMENT ON COLUMN agriculture_baseinfo.base_img IS '现场图片';
COMMENT ON COLUMN agriculture_baseinfo.base_des IS '基地描述';
COMMENT ON COLUMN agriculture_baseinfo.remark IS '备注';
COMMENT ON COLUMN agriculture_baseinfo.status IS '状态';
COMMENT ON COLUMN agriculture_baseinfo.order_num IS '排序';
COMMENT ON COLUMN agriculture_baseinfo.create_by IS '创建者ID';
COMMENT ON COLUMN agriculture_baseinfo.create_time IS '创建时间';
COMMENT ON COLUMN agriculture_baseinfo.update_by IS '修改人ID';
COMMENT ON COLUMN agriculture_baseinfo.update_time IS '修改时间';
COMMENT ON COLUMN agriculture_baseinfo.del_flag IS '删除标志（0代表存在 2代表删除）';
COMMENT ON COLUMN agriculture_baseinfo.base_coordinate IS '';
COMMENT ON COLUMN agriculture_baseinfo.create_dept IS '创建部门';
COMMENT ON COLUMN agriculture_baseinfo.tenant_id IS '租户ID';

-- 插入数据
BEGIN;
INSERT INTO agriculture_baseinfo (base_id, base_short_name, base_code, base_name, base_leader, leader_tel, base_address,
                                  base_area, base_altitude, base_img, base_des, remark, status, order_num, create_by,
                                  create_time, update_by, update_time, del_flag, base_coordinate, create_dept, tenant_id)
VALUES (6, '蔬菜基地002', '001', '蔬菜基地002', '乔军', '18112848484', '1', '400', 0,
        '/profile/iot/1/2024-0821-160931.jpg', '好基地123', '', '0', 0, 0, NULL, 0, '2024-09-20 12:36:40', '0',
        '120.147835,33.362915', 117, 114),
       (8, '花卉基地002', '005', '花卉基地002', '张三', '15888888888', '盐城', '500', 80,
        '/profile/iot/1/2024-0823-135300.png', '111', '', '0', 0, 0, NULL, 0, '2024-10-18 11:18:24', '0',
        '120.167413,33.342778', 101, 113),
       (13, '蔬菜基地001', '001', '蔬菜基地001', '乔军', '15888888888', '唐僧', '900', 90,
        '/profile/iot/9/2024-0923-094239.jpg', '111', '', '0', 0, 0, NULL, 0, '2024-09-23 09:42:40', '0',
        '120.142015,33.378896', 102, 114),
       (14, '花卉基地001', '001', '花卉基地001', '唐僧', '18888888888', '盐城', '300', 0,
        '/profile/iot/1/2024-0902-161057.jpg', '基地', '', '0', 0, 0, NULL, 0, '2024-09-25 10:24:16', '0',
        '120.13945,33.3685', 110, 113);

COMMIT;

-- ----------------------------
-- Table structure for agriculture_batch_task
-- ----------------------------
DROP TABLE IF EXISTS agriculture_batch_task;

CREATE TABLE agriculture_batch_task
(
    task_id        BIGINT        NOT NULL DEFAULT nextval('agriculture_batch_task_task_id_seq'::regclass),
    batch_id       BIGINT,
    task_head      BIGINT,
    task_head_name VARCHAR(255),
    task_name      VARCHAR(50)   NOT NULL DEFAULT '',
    plan_start     TIMESTAMP,
    plan_finish    TIMESTAMP,
    actual_start   TIMESTAMP,
    actual_finish  TIMESTAMP,
    task_detail    VARCHAR(2000) NOT NULL DEFAULT '',
    task_images    TEXT,
    task_videos    TEXT,
    remark         VARCHAR(2000) NOT NULL DEFAULT '',
    status         CHAR(1)       NOT NULL DEFAULT '0',
    order_num      INTEGER       NOT NULL DEFAULT 0,
    create_by      BIGINT        NOT NULL DEFAULT 0,
    create_time    TIMESTAMP,
    update_by      BIGINT                 DEFAULT 0,
    update_time    TIMESTAMP,
    del_flag       CHAR(1)       NOT NULL DEFAULT '0',
    PRIMARY KEY (task_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_batch_task_task_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_batch_task IS '批次任务表';
COMMENT ON COLUMN agriculture_batch_task.task_id IS '任务ID';
COMMENT ON COLUMN agriculture_batch_task.batch_id IS '批次ID';
COMMENT ON COLUMN agriculture_batch_task.task_head IS '任务负责人';
COMMENT ON COLUMN agriculture_batch_task.task_head_name IS '';
COMMENT ON COLUMN agriculture_batch_task.task_name IS '任务名称';
COMMENT ON COLUMN agriculture_batch_task.plan_start IS '计划开始日期';
COMMENT ON COLUMN agriculture_batch_task.plan_finish IS '计划结束日期';
COMMENT ON COLUMN agriculture_batch_task.actual_start IS '实际开始日期';
COMMENT ON COLUMN agriculture_batch_task.actual_finish IS '实际结束日期';
COMMENT ON COLUMN agriculture_batch_task.task_detail IS '任务详情';
COMMENT ON COLUMN agriculture_batch_task.task_images IS '图片资料';
COMMENT ON COLUMN agriculture_batch_task.task_videos IS '视频资料';
COMMENT ON COLUMN agriculture_batch_task.remark IS '备注';
COMMENT ON COLUMN agriculture_batch_task.status IS '0未分配 1已分配 2进行中 3已完成';
COMMENT ON COLUMN agriculture_batch_task.order_num IS '排序';
COMMENT ON COLUMN agriculture_batch_task.create_by IS '创建者ID';
COMMENT ON COLUMN agriculture_batch_task.create_time IS '创建时间';
COMMENT ON COLUMN agriculture_batch_task.update_by IS '修改人ID';
COMMENT ON COLUMN agriculture_batch_task.update_time IS '修改时间';
COMMENT ON COLUMN agriculture_batch_task.del_flag IS '删除标志（0代表存在 2代表删除）';

-- 插入数据
BEGIN;
INSERT INTO agriculture_batch_task (task_id, batch_id, task_head, task_head_name, task_name, plan_start, plan_finish,
                                    actual_start, actual_finish, task_detail, task_images, task_videos, remark, status,
                                    order_num, create_by, create_time, update_by, update_time, del_flag)
VALUES (1, 3, 6, '路人', '育苗', '2024-09-26 00:00:00', '2024-10-16 00:00:00', NULL, NULL, '',
        '/profile/iot/17/2024-1015-101854.png', NULL, '1233777', '1', 0, 17, '2024-09-26 14:38:28', 17,
        '2024-10-24 10:17:15', '0'),
       (2, 3, 17, NULL, '施肥', '2024-10-10 00:00:00', '2024-10-23 00:00:00', NULL, NULL, '', NULL, NULL, '', '0', 0,
        17, '2024-09-26 14:38:28', 0, NULL, '0'),
       (3, 4, 15, NULL, '育苗', '2024-10-15 00:00:00', '2024-11-04 00:00:00', NULL, NULL, '', NULL, NULL, '', '0', 0,
        17, '2024-10-15 10:19:51', 0, NULL, '2'),
       (4, 4, 15, NULL, '施肥', '2024-10-29 00:00:00', '2024-11-11 00:00:00', NULL, NULL, '', NULL, NULL, '', '0', 0,
        17, '2024-10-15 10:19:51', 0, NULL, '2'),
       (5, 3, 6, NULL, '新增任务', '2024-09-27 00:00:00', '2024-09-28 00:00:00', NULL, NULL, '插入新的任务', NULL, NULL,
        '', '3', 0, 17, '2024-10-15 10:24:12', 17, '2024-10-16 10:38:37', '0'),
       (6, 5, 15, NULL, '育苗', '2024-10-15 00:00:00', '2024-11-04 00:00:00', NULL, NULL, '', NULL, NULL, '', '0', 0,
        17, '2024-10-15 11:06:37', 0, NULL, '2'),
       (7, 5, 15, NULL, '施肥', '2024-10-29 00:00:00', '2024-11-11 00:00:00', NULL, NULL, '', NULL, NULL, '', '0', 0,
        17, '2024-10-15 11:06:37', 0, NULL, '2'),
       (8, 6, 17, NULL, '育苗', '2024-10-15 00:00:00', '2024-11-04 00:00:00', NULL, NULL, '', NULL, NULL, '', '0', 0,
        17, '2024-10-15 11:13:32', 17, '2024-10-15 13:31:40', '2'),
       (9, 6, 17, NULL, '施肥', '2024-10-29 00:00:00', '2024-11-11 00:00:00', NULL, NULL, '', NULL, NULL, '', '0', 0,
        17, '2024-10-15 11:13:32', 0, NULL, '2'),
       (10, 7, 15, NULL, '育苗', '2024-10-01 00:00:00', '2024-10-21 00:00:00', NULL, NULL, '', NULL, NULL, '', '0', 0,
        17, '2024-10-16 10:26:33', 0, NULL, '0'),
       (11, 7, 15, NULL, '施肥', '2024-10-15 00:00:00', '2024-10-28 00:00:00', NULL, NULL, '', NULL, NULL, '', '0', 0,
        17, '2024-10-16 10:26:33', 0, NULL, '0'),
       (12, 7, NULL, NULL, '测试任务', '2024-10-16 00:00:00', '2024-10-17 00:00:00', '2024-10-16 00:00:00',
        '2024-10-18 00:00:00', '测试', NULL, NULL, '', '0', 0, 17, '2024-10-16 11:07:00', 15, '2024-10-16 11:07:45',
        '0'),
       (13, 8, 5, '杨成达', '播种', '2024-10-01 00:00:00', '2024-10-21 00:00:00', '2024-10-01 00:00:00',
        '2024-10-08 00:00:00', '', NULL, NULL, '2222', '0', 0, 12, '2024-10-18 14:47:07', 12, '2024-10-18 14:49:56',
        '0'),
       (14, 8, 12, NULL, '浇水', '2024-10-22 00:00:00', '2024-11-04 00:00:00', NULL, NULL, '', NULL, NULL, '', '0', 0,
        12, '2024-10-18 14:47:07', 0, NULL, '0'),
       (15, 8, NULL, NULL, '额外添加任务', '2024-10-02 00:00:00', '2024-10-04 00:00:00', NULL, NULL, '', NULL, NULL, '',
        '0', 0, 12, '2024-10-18 14:48:05', 0, NULL, '0');

COMMIT;

-- ----------------------------
-- Table structure for agriculture_cost_employee
-- ----------------------------
DROP TABLE IF EXISTS agriculture_cost_employee;

CREATE TABLE agriculture_cost_employee
(
    cost_id        BIGINT        NOT NULL DEFAULT nextval('agriculture_cost_employee_cost_id_seq'::regclass),
    task_id        BIGINT        NOT NULL DEFAULT 0,
    employee_id    BIGINT        NOT NULL DEFAULT 0,
    working_hours  NUMERIC(8, 2) NOT NULL DEFAULT 0.00,
    working_start  TIMESTAMP,
    working_finish TIMESTAMP,
    remark         VARCHAR(2000) NOT NULL DEFAULT '',
    status         CHAR(1)       NOT NULL DEFAULT '0',
    order_num      INTEGER       NOT NULL DEFAULT 0,
    create_by      BIGINT        NOT NULL DEFAULT 0,
    create_time    TIMESTAMP,
    update_by      BIGINT                 DEFAULT 0,
    update_time    TIMESTAMP,
    del_flag       CHAR(1)       NOT NULL DEFAULT '0',
    PRIMARY KEY (cost_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_cost_employee_cost_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_cost_employee IS '人工工时表';
COMMENT ON COLUMN agriculture_cost_employee.cost_id IS 'ID';
COMMENT ON COLUMN agriculture_cost_employee.task_id IS '任务ID';
COMMENT ON COLUMN agriculture_cost_employee.employee_id IS '雇员ID';
COMMENT ON COLUMN agriculture_cost_employee.working_hours IS '工时';
COMMENT ON COLUMN agriculture_cost_employee.working_start IS '开始日期';
COMMENT ON COLUMN agriculture_cost_employee.working_finish IS '结束日期';
COMMENT ON COLUMN agriculture_cost_employee.remark IS '备注';
COMMENT ON COLUMN agriculture_cost_employee.status IS '状态';
COMMENT ON COLUMN agriculture_cost_employee.order_num IS '排序';
COMMENT ON COLUMN agriculture_cost_employee.create_by IS '创建者ID';
COMMENT ON COLUMN agriculture_cost_employee.create_time IS '创建时间';
COMMENT ON COLUMN agriculture_cost_employee.update_by IS '修改人ID';
COMMENT ON COLUMN agriculture_cost_employee.update_time IS '修改时间';
COMMENT ON COLUMN agriculture_cost_employee.del_flag IS '删除标志（0代表存在 2代表删除）';

-- 插入数据
BEGIN;
INSERT INTO agriculture_cost_employee (cost_id, task_id, employee_id, working_hours, working_start, working_finish,
                                       remark, status, order_num, create_by, create_time, update_by, update_time,
                                       del_flag)
VALUES (1, 1, 6, 30.00, '2024-09-26 00:00:00', '2024-09-27 00:00:00', '', '0', 0, 17, '2024-09-26 14:55:54', 0, NULL,
        '0');

COMMIT;

-- ----------------------------
-- Table structure for agriculture_cost_machine
-- ----------------------------
DROP TABLE IF EXISTS agriculture_cost_machine;

CREATE TABLE agriculture_cost_machine
(
    cost_id        BIGINT        NOT NULL DEFAULT nextval('agriculture_cost_machine_cost_id_seq'::regclass),
    task_id        BIGINT        NOT NULL DEFAULT 0,
    machine_id     BIGINT        NOT NULL DEFAULT 0,
    machine_count  INTEGER       NOT NULL DEFAULT 0,
    working_hours  NUMERIC(8, 2) NOT NULL DEFAULT 0.00,
    working_start  TIMESTAMP,
    working_finish TIMESTAMP,
    remark         VARCHAR(2000) NOT NULL DEFAULT '',
    status         CHAR(1)       NOT NULL DEFAULT '0',
    order_num      INTEGER       NOT NULL DEFAULT 0,
    create_by      BIGINT        NOT NULL DEFAULT 0,
    create_time    TIMESTAMP,
    update_by      BIGINT                 DEFAULT 0,
    update_time    TIMESTAMP,
    del_flag       CHAR(1)       NOT NULL DEFAULT '0',
    PRIMARY KEY (cost_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_cost_machine_cost_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_cost_machine IS '机械工时表';
COMMENT ON COLUMN agriculture_cost_machine.cost_id IS 'ID';
COMMENT ON COLUMN agriculture_cost_machine.task_id IS '任务ID';
COMMENT ON COLUMN agriculture_cost_machine.machine_id IS '机械ID';
COMMENT ON COLUMN agriculture_cost_machine.machine_count IS '机械数量';
COMMENT ON COLUMN agriculture_cost_machine.working_hours IS '工时';
COMMENT ON COLUMN agriculture_cost_machine.working_start IS '开始日期';
COMMENT ON COLUMN agriculture_cost_machine.working_finish IS '结束日期';
COMMENT ON COLUMN agriculture_cost_machine.remark IS '备注';
COMMENT ON COLUMN agriculture_cost_machine.status IS '状态';
COMMENT ON COLUMN agriculture_cost_machine.order_num IS '排序';
COMMENT ON COLUMN agriculture_cost_machine.create_by IS '创建者ID';
COMMENT ON COLUMN agriculture_cost_machine.create_time IS '创建时间';
COMMENT ON COLUMN agriculture_cost_machine.update_by IS '修改人ID';
COMMENT ON COLUMN agriculture_cost_machine.update_time IS '修改时间';
COMMENT ON COLUMN agriculture_cost_machine.del_flag IS '删除标志（0代表存在 2代表删除）';

-- 插入数据
BEGIN;
INSERT INTO agriculture_cost_machine (cost_id, task_id, machine_id, machine_count, working_hours, working_start,
                                      working_finish, remark, status, order_num, create_by, create_time, update_by,
                                      update_time, del_flag)
VALUES (1, 1, 4, 2, 2.00, '2024-10-15 00:00:00', '2024-10-16 00:00:00', '', '0', 0, 17, '2024-10-15 10:18:10', 0, NULL,
        '0');

COMMIT;

-- ----------------------------
-- Table structure for agriculture_cost_material
-- ----------------------------
DROP TABLE IF EXISTS agriculture_cost_material;

CREATE TABLE agriculture_cost_material
(
    cost_id        BIGINT        NOT NULL DEFAULT nextval('agriculture_cost_material_cost_id_seq'::regclass),
    task_id        BIGINT        NOT NULL DEFAULT 0,
    material_id    BIGINT        NOT NULL DEFAULT 0,
    material_count INTEGER       NOT NULL DEFAULT 0,
    measure_unit   VARCHAR(10)   NOT NULL DEFAULT '',
    working_start  TIMESTAMP,
    working_finish TIMESTAMP,
    remark         VARCHAR(2000) NOT NULL DEFAULT '',
    status         CHAR(1)       NOT NULL DEFAULT '0',
    order_num      INTEGER       NOT NULL DEFAULT 0,
    create_by      BIGINT        NOT NULL DEFAULT 0,
    create_time    TIMESTAMP,
    update_by      BIGINT                 DEFAULT 0,
    update_time    TIMESTAMP,
    del_flag       CHAR(1)       NOT NULL DEFAULT '0',
    PRIMARY KEY (cost_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_cost_material_cost_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_cost_material IS '农资用量表';
COMMENT ON COLUMN agriculture_cost_material.cost_id IS 'ID';
COMMENT ON COLUMN agriculture_cost_material.task_id IS '任务ID';
COMMENT ON COLUMN agriculture_cost_material.material_id IS '农资ID';
COMMENT ON COLUMN agriculture_cost_material.material_count IS '使用数量';
COMMENT ON COLUMN agriculture_cost_material.measure_unit IS '计量单位';
COMMENT ON COLUMN agriculture_cost_material.working_start IS '开始日期';
COMMENT ON COLUMN agriculture_cost_material.working_finish IS '结束日期';
COMMENT ON COLUMN agriculture_cost_material.remark IS '备注';
COMMENT ON COLUMN agriculture_cost_material.status IS '状态';
COMMENT ON COLUMN agriculture_cost_material.order_num IS '排序';
COMMENT ON COLUMN agriculture_cost_material.create_by IS '创建者ID';
COMMENT ON COLUMN agriculture_cost_material.create_time IS '创建时间';
COMMENT ON COLUMN agriculture_cost_material.update_by IS '修改人ID';
COMMENT ON COLUMN agriculture_cost_material.update_time IS '修改时间';
COMMENT ON COLUMN agriculture_cost_material.del_flag IS '删除标志（0代表存在 2代表删除）';

-- 插入数据
BEGIN;
INSERT INTO agriculture_cost_material (cost_id, task_id, material_id, material_count, measure_unit, working_start,
                                       working_finish, remark, status, order_num, create_by, create_time, update_by,
                                       update_time, del_flag)
VALUES (1, 1, 6, 2, '袋', '2024-10-15 00:00:00', '2024-10-16 00:00:00', '', '0', 0, 17, '2024-10-15 10:18:33', 0, NULL,
        '0');

COMMIT;

-- ----------------------------
-- Table structure for agriculture_crop_batch
-- ----------------------------
DROP TABLE IF EXISTS agriculture_crop_batch;

CREATE TABLE agriculture_crop_batch
(
    batch_id     BIGINT         NOT NULL DEFAULT nextval('agriculture_crop_batch_batch_id_seq'::regclass),
    batch_name   VARCHAR(50)    NOT NULL,
    germplasm_id BIGINT         NOT NULL,
    land_id      BIGINT         NOT NULL DEFAULT 0,
    crop_area    NUMERIC(10, 2) NOT NULL DEFAULT 0.00,
    start_time   TIMESTAMP,
    remark       VARCHAR(2000)  NOT NULL DEFAULT '',
    status       CHAR(1)        NOT NULL DEFAULT '0',
    order_num    INTEGER        NOT NULL DEFAULT 0,
    create_by    BIGINT         NOT NULL DEFAULT 0,
    create_time  TIMESTAMP,
    update_by    BIGINT                  DEFAULT 0,
    update_time  TIMESTAMP,
    del_flag     CHAR(1)        NOT NULL DEFAULT '0',
    batch_head   BIGINT         NOT NULL DEFAULT 0,
    tenant_id    BIGINT         NOT NULL DEFAULT 0,
    base_id      BIGINT         NOT NULL DEFAULT 0,
    create_dept      BIGINT         NOT NULL DEFAULT 0,
    user_id      BIGINT         NOT NULL DEFAULT 0,
    PRIMARY KEY (batch_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_crop_batch_batch_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_crop_batch IS '作物批次表';
COMMENT ON COLUMN agriculture_crop_batch.batch_id IS '批次ID';
COMMENT ON COLUMN agriculture_crop_batch.batch_name IS '批次名称';
COMMENT ON COLUMN agriculture_crop_batch.germplasm_id IS '种质ID';
COMMENT ON COLUMN agriculture_crop_batch.land_id IS '地块ID';
COMMENT ON COLUMN agriculture_crop_batch.crop_area IS '种植面积（亩）';
COMMENT ON COLUMN agriculture_crop_batch.start_time IS '开始时间';
COMMENT ON COLUMN agriculture_crop_batch.remark IS '备注';
COMMENT ON COLUMN agriculture_crop_batch.status IS '状态';
COMMENT ON COLUMN agriculture_crop_batch.order_num IS '排序';
COMMENT ON COLUMN agriculture_crop_batch.create_by IS '创建者ID';
COMMENT ON COLUMN agriculture_crop_batch.create_time IS '创建时间';
COMMENT ON COLUMN agriculture_crop_batch.update_by IS '修改人ID';
COMMENT ON COLUMN agriculture_crop_batch.update_time IS '修改时间';
COMMENT ON COLUMN agriculture_crop_batch.del_flag IS '删除标志（0代表存在 2代表删除）';
COMMENT ON COLUMN agriculture_crop_batch.batch_head IS '负责人Id';
COMMENT ON COLUMN agriculture_crop_batch.tenant_id IS '租户ID';
COMMENT ON COLUMN agriculture_crop_batch.base_id IS '基地ID';
COMMENT ON COLUMN agriculture_crop_batch.create_dept IS '部门ID';
COMMENT ON COLUMN agriculture_crop_batch.user_id IS '用户ID';

-- 插入数据
BEGIN;
INSERT INTO agriculture_crop_batch (batch_id, batch_name, germplasm_id, land_id, crop_area, start_time, remark, status,
                                    order_num, create_by, create_time, update_by, update_time, del_flag, batch_head,
                                    tenant_id, base_id, create_dept, user_id)
VALUES (1, '黄瓜', 4, 0, 30.00, '2024-09-01 00:00:00', '', '0', 0, 9, '2024-09-18 11:44:21', 0, NULL, '2', 10, 113, 101,
        101, 9);

INSERT INTO agriculture_crop_batch (batch_id, batch_name, germplasm_id, land_id, crop_area, start_time, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, batch_head, tenant_id, base_id, create_dept, user_id) VALUES
    (2, '番茄', 5, 0, 40.00, '2024-09-01 00:00:00', '', '0', 0, 9, '2024-09-18 11:45:23', 0, NULL, '2', 10, 113, 101, 101, 9);
INSERT INTO agriculture_crop_batch (batch_id, batch_name, germplasm_id, land_id, crop_area, start_time, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, batch_head, tenant_id, base_id, create_dept, user_id) VALUES
    (3, '兰花培育001', 6, 0, 300.00, '2024-09-26 00:00:00', '', '0', 0, 17, '2024-09-26 14:38:28', 0, NULL, '0', 17, 113, 110, 110, 17);
INSERT INTO agriculture_crop_batch (batch_id, batch_name, germplasm_id, land_id, crop_area, start_time, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, batch_head, tenant_id, base_id, create_dept, user_id) VALUES
    (4, '测试批次', 6, 0, 300.00, '2024-10-15 00:00:00', '', '0', 0, 17, '2024-10-15 10:19:51', 0, NULL, '2', 15, 113, 110, 110, 17);
INSERT INTO agriculture_crop_batch (batch_id, batch_name, germplasm_id, land_id, crop_area, start_time, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, batch_head, tenant_id, base_id, create_dept, user_id) VALUES
    (5, '测试', 6, 0, 300.00, '2024-10-15 00:00:00', '', '0', 0, 17, '2024-10-15 11:06:37', 0, NULL, '2', 15, 113, 110, 110, 17);
INSERT INTO agriculture_crop_batch (batch_id, batch_name, germplasm_id, land_id, crop_area, start_time, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, batch_head, tenant_id, base_id, create_dept, user_id) VALUES
    (6, '333', 6, 0, 333.00, '2024-10-15 00:00:00', '', '0', 0, 17, '2024-10-15 11:13:32', 0, NULL, '2', 17, 113, 110, 110, 17);
INSERT INTO agriculture_crop_batch (batch_id, batch_name, germplasm_id, land_id, crop_area, start_time, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, batch_head, tenant_id, base_id, create_dept, user_id) VALUES
    (7, '测试批次', 6, 0, 300.00, '2024-10-01 00:00:00', '', '0', 0, 17, '2024-10-16 10:26:33', 0, NULL, '0', 15, 113, 110, 110, 17);
INSERT INTO agriculture_crop_batch (batch_id, batch_name, germplasm_id, land_id, crop_area, start_time, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, batch_head, tenant_id, base_id, create_dept, user_id) VALUES
    (8, '测试', 4, 0, 300.00, '2024-10-01 00:00:00', '', '0', 0, 12, '2024-10-18 14:47:07', 0, NULL, '0', 12, 113, 101, 103, 12);
COMMIT;


-- ----------------------------
-- Table structure for agriculture_employee
-- ----------------------------
DROP TABLE IF EXISTS agriculture_employee;

CREATE TABLE agriculture_employee
(
    employee_id      BIGINT        NOT NULL DEFAULT nextval('agriculture_employee_employee_id_seq'::regclass),
    employee_code    VARCHAR(20)   NOT NULL DEFAULT '',
    employee_name    VARCHAR(10)   NOT NULL DEFAULT '',
    employee_type    CHAR(1)       NOT NULL DEFAULT '0',
    employee_tel     VARCHAR(20)   NOT NULL DEFAULT '',
    employee_sex     CHAR(1)       NOT NULL DEFAULT '0',
    employee_address VARCHAR(200)  NOT NULL DEFAULT '',
    remark           VARCHAR(2000) NOT NULL DEFAULT '',
    status           CHAR(1)       NOT NULL DEFAULT '0',
    order_num        INTEGER       NOT NULL DEFAULT 0,
    create_by        BIGINT        NOT NULL DEFAULT 0,
    create_time      TIMESTAMP,
    update_by        BIGINT                 DEFAULT 0,
    update_time      TIMESTAMP,
    del_flag         CHAR(1)       NOT NULL DEFAULT '0',
    tenant_id        BIGINT        NOT NULL DEFAULT 0,
    base_id          BIGINT        NOT NULL DEFAULT 0,
    create_dept          BIGINT        NOT NULL DEFAULT 0,
    user_id          BIGINT        NOT NULL DEFAULT 0,
    PRIMARY KEY (employee_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_employee_employee_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_employee IS '雇员表';
COMMENT ON COLUMN agriculture_employee.employee_id IS '雇员ID';
COMMENT ON COLUMN agriculture_employee.employee_code IS '编码';
COMMENT ON COLUMN agriculture_employee.employee_name IS '姓名';
COMMENT ON COLUMN agriculture_employee.employee_type IS '字典 agriculture_employee_type';
COMMENT ON COLUMN agriculture_employee.employee_tel IS '手机号码';
COMMENT ON COLUMN agriculture_employee.employee_sex IS '字典 sys_user_sex';
COMMENT ON COLUMN agriculture_employee.employee_address IS '地址';
COMMENT ON COLUMN agriculture_employee.remark IS '备注';
COMMENT ON COLUMN agriculture_employee.status IS '状态';
COMMENT ON COLUMN agriculture_employee.order_num IS '排序';
COMMENT ON COLUMN agriculture_employee.create_by IS '创建者ID';
COMMENT ON COLUMN agriculture_employee.create_time IS '创建时间';
COMMENT ON COLUMN agriculture_employee.update_by IS '修改人ID';
COMMENT ON COLUMN agriculture_employee.update_time IS '修改时间';
COMMENT ON COLUMN agriculture_employee.del_flag IS '删除标志（0代表存在 2代表删除）';
COMMENT ON COLUMN agriculture_employee.tenant_id IS '租户ID';
COMMENT ON COLUMN agriculture_employee.base_id IS '基地ID';
COMMENT ON COLUMN agriculture_employee.create_dept IS '部门ID';
COMMENT ON COLUMN agriculture_employee.user_id IS '用户ID';

-- 插入数据
BEGIN;
INSERT INTO agriculture_employee (employee_id, employee_code, employee_name, employee_type, employee_tel, employee_sex, employee_address, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (1, '1001', '张三', '0', '1', '0', '江苏省盐城市', '', '0', 0, 10, '2023-05-17 13:57:38', 0, '2023-05-17 16:10:50', '0', 0, 0, 0, 1);
INSERT INTO agriculture_employee (employee_id, employee_code, employee_name, employee_type, employee_tel, employee_sex, employee_address, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (2, '002', '李四', '0', '18112857630', '0', '123', '', '0', 0, 1, '2023-05-18 09:16:02', 0, NULL, '2', 0, 0, 0, 1);
INSERT INTO agriculture_employee (employee_id, employee_code, employee_name, employee_type, employee_tel, employee_sex, employee_address, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (3, '002', '乔军', '0', '18112857630', '0', '盐城市', '', '0', 0, 1, '2023-06-12 14:18:44', 0, NULL, '0', 0, 0, 0, 1);
INSERT INTO agriculture_employee (employee_id, employee_code, employee_name, employee_type, employee_tel, employee_sex, employee_address, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (4, '001', '姚琼', '0', '18111118888', '1', '高教公寓', '', '0', 0, 8, '2023-08-26 13:46:51', 0, NULL, '2', 0, 0, 0, 1);
INSERT INTO agriculture_employee (employee_id, employee_code, employee_name, employee_type, employee_tel, employee_sex, employee_address, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (5, '002', '杨成达', '0', '18112857630', '0', '盐城市亭湖区', '', '0', 0, 10, '2024-08-19 10:56:25', 0, NULL, '0', 113, 101, 103, 10);
INSERT INTO agriculture_employee (employee_id, employee_code, employee_name, employee_type, employee_tel, employee_sex, employee_address, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (6, '002', '路人', '0', '18112822222', '0', '222', '', '0', 0, 17, '2024-09-26 14:46:23', 0, NULL, '0', 113, 110, 110, 17);
COMMIT;


-- ----------------------------
-- Table structure for agriculture_germplasm
-- ----------------------------
DROP TABLE IF EXISTS agriculture_germplasm;

CREATE TABLE agriculture_germplasm
(
    germplasm_id      BIGINT        NOT NULL DEFAULT nextval('agriculture_germplasm_germplasm_id_seq'::regclass),
    crop_name         VARCHAR(50)   NOT NULL DEFAULT '',
    crop_en_name      VARCHAR(50)   NOT NULL DEFAULT '',
    germplasm_name    VARCHAR(50)   NOT NULL DEFAULT '',
    germplasm_en_name VARCHAR(50)   NOT NULL DEFAULT '',
    germplasm_img     VARCHAR(100)  NOT NULL DEFAULT '',
    germplasm_des     VARCHAR(500)  NOT NULL DEFAULT '',
    remark            VARCHAR(2000) NOT NULL DEFAULT '',
    status            CHAR(1)       NOT NULL DEFAULT '0',
    order_num         INTEGER       NOT NULL DEFAULT 0,
    create_by         BIGINT        NOT NULL DEFAULT 0,
    create_time       TIMESTAMP,
    update_by         BIGINT                 DEFAULT 0,
    update_time       TIMESTAMP,
    del_flag          CHAR(1)       NOT NULL DEFAULT '0',
    tenant_id         BIGINT        NOT NULL DEFAULT 0,
    base_id           BIGINT        NOT NULL DEFAULT 0,
    create_dept           BIGINT        NOT NULL DEFAULT 0,
    user_id           BIGINT        NOT NULL DEFAULT 0,
    PRIMARY KEY (germplasm_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_germplasm_germplasm_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_germplasm IS '种质表';
COMMENT ON COLUMN agriculture_germplasm.germplasm_id IS '种质ID';
COMMENT ON COLUMN agriculture_germplasm.crop_name IS '作物名称';
COMMENT ON COLUMN agriculture_germplasm.crop_en_name IS '作物英文名称';
COMMENT ON COLUMN agriculture_germplasm.germplasm_name IS '种质名称';
COMMENT ON COLUMN agriculture_germplasm.germplasm_en_name IS '种质英文名称';
COMMENT ON COLUMN agriculture_germplasm.germplasm_img IS '种质图片';
COMMENT ON COLUMN agriculture_germplasm.germplasm_des IS '宣传语';
COMMENT ON COLUMN agriculture_germplasm.remark IS '备注';
COMMENT ON COLUMN agriculture_germplasm.status IS '状态';
COMMENT ON COLUMN agriculture_germplasm.order_num IS '排序';
COMMENT ON COLUMN agriculture_germplasm.create_by IS '创建者ID';
COMMENT ON COLUMN agriculture_germplasm.create_time IS '创建时间';
COMMENT ON COLUMN agriculture_germplasm.update_by IS '修改人ID';
COMMENT ON COLUMN agriculture_germplasm.update_time IS '修改时间';
COMMENT ON COLUMN agriculture_germplasm.del_flag IS '删除标志（0代表存在 2代表删除）';
COMMENT ON COLUMN agriculture_germplasm.tenant_id IS '租户ID';
COMMENT ON COLUMN agriculture_germplasm.base_id IS '基地ID';
COMMENT ON COLUMN agriculture_germplasm.create_dept IS '部门ID';
COMMENT ON COLUMN agriculture_germplasm.user_id IS '用户ID';

-- 插入数据
BEGIN;
INSERT INTO agriculture_germplasm (germplasm_id, crop_name, crop_en_name, germplasm_name, germplasm_en_name, germplasm_img, germplasm_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (1, '西瓜', 'watermelon', '西瓜', 'watermelon', '/profile/iot/1/2023-0803-095310.png', '西瓜是一种夏季消暑的好选择，其含有丰富的水分和天然的清凉成分，能够有效地降低体温。除了降热解暑，西瓜皮还可以用来炒着吃或伴着吃，制成药材来治疗肾炎水肿、肝病黄疸等疾病，甚至可以作为美容材料用来敷脸。因此，夏季食用西瓜不仅能够解暑，还能保持身体健康。', '1', '0', 0, 1, '2023-05-18 09:35:37', 1, '2023-08-03 09:53:12', '0', 0, 0, 0, 0);
INSERT INTO agriculture_germplasm (germplasm_id, crop_name, crop_en_name, germplasm_name, germplasm_en_name, germplasm_img, germplasm_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (2, '番茄', 'tomato', '番茄', 'tomato', '/profile/iot/1/2023-0803-095406.png', '1212', '', '0', 0, 1, '2023-05-23 21:01:12', 1, '2023-08-03 09:54:08', '0', 0, 0, 0, 0);
INSERT INTO agriculture_germplasm (germplasm_id, crop_name, crop_en_name, germplasm_name, germplasm_en_name, germplasm_img, germplasm_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (3, '胡萝卜', 'carrot', '胡萝卜', 'carrot', '/profile/iot/1/2023-0803-095052.png', '胡萝卜（Daucus carota var. sativa Hoffm.），是伞形科胡萝卜属一年生或二年生草本植物。转基因胡萝卜：表面较光滑。胡萝卜根肉质，长圆锥形，呈橙红色或黄色；茎单生，全株被白色粗硬毛；叶片长圆形，先端尖锐；茎生叶近无柄，有叶鞘，末回裂片小或细长；花通常白色，有时带淡红色；花柄不等长；', '', '0', 0, 9, '2023-08-03 09:51:18', 9, NULL, '0', 0, 0, 0, 0);
INSERT INTO agriculture_germplasm (germplasm_id, crop_name, crop_en_name, germplasm_name, germplasm_en_name, germplasm_img, germplasm_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (4, '黄瓜', 'huanggua', '黄瓜', 'huanggua', '/profile/iot/10/2024-0819-113117.jpg', '好吃的黄瓜', '', '0', 0, 10, '2024-08-19 11:31:26', 0, NULL, '0', 113, 101, 103, 10);
INSERT INTO agriculture_germplasm (germplasm_id, crop_name, crop_en_name, germplasm_name, germplasm_en_name, germplasm_img, germplasm_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (5, '番茄', 'fanqie', '番茄', 'fanqie', '/profile/iot/9/2024-0918-114314.jpg', '123', '', '0', 0, 9, '2024-09-18 11:43:18', 0, NULL, '0', 113, 101, 101, 9);
INSERT INTO agriculture_germplasm (germplasm_id, crop_name, crop_en_name, germplasm_name, germplasm_en_name, germplasm_img, germplasm_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (6, '兰花', 'lanhua', '兰花根茎', 'lanhuagenjin', '/profile/iot/17/2024-0926-143656.jpg', '兰花', '', '0', 0, 17, '2024-09-26 14:37:00', 0, NULL, '0', 113, 110, 110, 17);
COMMIT;


-- ----------------------------
-- Table structure for agriculture_germplasm_intro
-- ----------------------------
DROP TABLE IF EXISTS agriculture_germplasm_intro;

CREATE TABLE agriculture_germplasm_intro (
                                             intro_id BIGINT NOT NULL DEFAULT nextval('agriculture_germplasm_intro_intro_id_seq'::regclass),
                                             germplasm_id BIGINT NOT NULL,
                                             intro_name VARCHAR(50) NOT NULL DEFAULT '',
                                             intro_img VARCHAR(100) NOT NULL DEFAULT '',
                                             intro_des VARCHAR(1000) NOT NULL DEFAULT '',
                                             remark VARCHAR(2000) NOT NULL DEFAULT '',
                                             status CHAR(1) NOT NULL DEFAULT '0',
                                             order_num INTEGER NOT NULL DEFAULT 0,
                                             create_by BIGINT NOT NULL DEFAULT 0,
                                             create_time TIMESTAMP,
                                             update_by BIGINT DEFAULT 0,
                                             update_time TIMESTAMP,
                                             del_flag CHAR(1) NOT NULL DEFAULT '0',
                                             PRIMARY KEY (intro_id)
);

-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_germplasm_intro_intro_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_germplasm_intro IS '种质介绍表';
COMMENT ON COLUMN agriculture_germplasm_intro.intro_id IS '介绍ID';
COMMENT ON COLUMN agriculture_germplasm_intro.germplasm_id IS '种质ID';
COMMENT ON COLUMN agriculture_germplasm_intro.intro_name IS '名称';
COMMENT ON COLUMN agriculture_germplasm_intro.intro_img IS '图片';
COMMENT ON COLUMN agriculture_germplasm_intro.intro_des IS '描述';
COMMENT ON COLUMN agriculture_germplasm_intro.remark IS '备注';
COMMENT ON COLUMN agriculture_germplasm_intro.status IS '状态';
COMMENT ON COLUMN agriculture_germplasm_intro.order_num IS '排序';
COMMENT ON COLUMN agriculture_germplasm_intro.create_by IS '创建者ID';
COMMENT ON COLUMN agriculture_germplasm_intro.create_time IS '创建时间';
COMMENT ON COLUMN agriculture_germplasm_intro.update_by IS '修改人ID';
COMMENT ON COLUMN agriculture_germplasm_intro.update_time IS '修改时间';
COMMENT ON COLUMN agriculture_germplasm_intro.del_flag IS '删除标志（0代表存在 2代表删除）';

-- 插入数据
BEGIN;
INSERT INTO agriculture_germplasm_intro (intro_id, germplasm_id, intro_name, intro_img, intro_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (1, 2, '1', '/profile/iot/1/2023-0523-215817.png', '111', '', '0', 0, 0, '2023-05-23 21:58:19', 0, NULL, '0');
INSERT INTO agriculture_germplasm_intro (intro_id, germplasm_id, intro_name, intro_img, intro_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (2, 2, '121', '/profile/iot/1/2023-0523-220029.png', '1121', '', '0', 0, 0, '2023-05-23 22:00:32', 0, NULL, '0');
INSERT INTO agriculture_germplasm_intro (intro_id, germplasm_id, intro_name, intro_img, intro_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (3, 1, '介绍测试', '/profile/iot/1/2023-0524-135509.png', '111', '', '0', 0, 0, '2023-05-24 13:55:12', 0, NULL, '0');
COMMIT;

-- ----------------------------
-- Table structure for agriculture_land
-- ----------------------------
DROP TABLE IF EXISTS agriculture_land;

CREATE TABLE agriculture_land
(
    land_id        BIGINT         NOT NULL DEFAULT nextval('agriculture_land_land_id_seq'::regclass),
    land_name      VARCHAR(50)    NOT NULL DEFAULT '',
    land_type      CHAR(1)        NOT NULL DEFAULT '0',
    land_area      NUMERIC(10, 2) NOT NULL DEFAULT '0.00',
    stroke_weight  SMALLINT       NOT NULL DEFAULT '0',
    stroke_color   VARCHAR(50)    NOT NULL DEFAULT '',
    stroke_opacity NUMERIC(10, 2) NOT NULL DEFAULT '0.00',
    land_path      VARCHAR(1000)  NOT NULL DEFAULT '',
    fill_color     VARCHAR(50)    NOT NULL DEFAULT '',
    fill_opacity   NUMERIC(10, 2) NOT NULL DEFAULT '0.00',
    current_batch  BIGINT         NOT NULL DEFAULT '0',
    remark         VARCHAR(2000)  NOT NULL DEFAULT '',
    status         CHAR(1)        NOT NULL DEFAULT '0',
    order_num      INTEGER        NOT NULL DEFAULT 0,
    create_by      BIGINT         NOT NULL DEFAULT 0,
    create_time    TIMESTAMP,
    update_by      BIGINT                  DEFAULT 0,
    update_time    TIMESTAMP,
    del_flag       CHAR(1)        NOT NULL DEFAULT '0',
    tenant_id      BIGINT         NOT NULL DEFAULT 0,
    base_id        BIGINT         NOT NULL DEFAULT 0,
    create_dept        BIGINT         NOT NULL DEFAULT 0,
    user_id        BIGINT         NOT NULL DEFAULT 0,
    PRIMARY KEY (land_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_land_land_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_land IS '地块表';
COMMENT ON COLUMN agriculture_land.land_id IS '地块ID';
COMMENT ON COLUMN agriculture_land.land_name IS '地块名称';
COMMENT ON COLUMN agriculture_land.land_type IS '字典 agriculture_land_type';
COMMENT ON COLUMN agriculture_land.land_area IS '地块面积';
COMMENT ON COLUMN agriculture_land.stroke_weight IS '边框宽度';
COMMENT ON COLUMN agriculture_land.stroke_color IS '边框颜色';
COMMENT ON COLUMN agriculture_land.stroke_opacity IS '边框透明度';
COMMENT ON COLUMN agriculture_land.land_path IS '地块路径';
COMMENT ON COLUMN agriculture_land.fill_color IS '地块背景颜色';
COMMENT ON COLUMN agriculture_land.fill_opacity IS '地块透明度';
COMMENT ON COLUMN agriculture_land.current_batch IS '当前种植批次';
COMMENT ON COLUMN agriculture_land.remark IS '备注';
COMMENT ON COLUMN agriculture_land.status IS '状态';
COMMENT ON COLUMN agriculture_land.order_num IS '排序';
COMMENT ON COLUMN agriculture_land.create_by IS '创建者ID';
COMMENT ON COLUMN agriculture_land.create_time IS '创建时间';
COMMENT ON COLUMN agriculture_land.update_by IS '修改人ID';
COMMENT ON COLUMN agriculture_land.update_time IS '修改时间';
COMMENT ON COLUMN agriculture_land.del_flag IS '删除标志（0代表存在 2代表删除）';
COMMENT ON COLUMN agriculture_land.tenant_id IS '租户ID';
COMMENT ON COLUMN agriculture_land.base_id IS '基地ID';
COMMENT ON COLUMN agriculture_land.create_dept IS '部门ID';
COMMENT ON COLUMN agriculture_land.user_id IS '用户ID';

-- 插入数据
BEGIN;
INSERT INTO agriculture_land (land_id, land_name, land_type, land_area, stroke_weight, stroke_color, stroke_opacity, land_path, fill_color, fill_opacity, current_batch, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (1, '001地块', '0', 100.00, 1, '#1AC233', 0.80, '120.160573,33.348647|120.162569,33.346353|120.164607,33.347787|120.162676,33.349974', '#EDA218', 0.80, 0, '', '0', 0, 17, '2024-09-19 14:04:49', 0, NULL, '0', 113, 110, 110, 17);
INSERT INTO agriculture_land (land_id, land_name, land_type, land_area, stroke_weight, stroke_color, stroke_opacity, land_path, fill_color, fill_opacity, current_batch, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (2, '测试地块', '0', 100.00, 1, '#1AC233', 0.80, '120.139741,33.377878|120.140062,33.374832|120.144762,33.376051|120.14356,33.378667', '#402009', 0.80, 0, '', '0', 0, 12, '2024-10-18 14:51:35', 0, NULL, '0', 113, 101, 103, 12);
COMMIT;


-- ----------------------------
-- Table structure for agriculture_machine_info
-- ----------------------------
DROP TABLE IF EXISTS agriculture_machine_info;

CREATE TABLE agriculture_machine_info
(
    machine_id      BIGINT        NOT NULL DEFAULT nextval('agriculture_machine_info_machine_id_seq'::regclass),
    machine_code    VARCHAR(20)   NOT NULL DEFAULT '',
    machine_name    VARCHAR(50)   NOT NULL DEFAULT '',
    machine_type_id BIGINT        NOT NULL DEFAULT '0',
    measure_unit    VARCHAR(10)   NOT NULL DEFAULT '',
    remark          VARCHAR(2000) NOT NULL DEFAULT '',
    status          CHAR(1)       NOT NULL DEFAULT '0',
    order_num       INTEGER       NOT NULL DEFAULT 0,
    create_by       BIGINT        NOT NULL DEFAULT 0,
    create_time     TIMESTAMP,
    update_by       BIGINT                 DEFAULT 0,
    update_time     TIMESTAMP,
    del_flag        CHAR(1)       NOT NULL DEFAULT '0',
    tenant_id       BIGINT        NOT NULL DEFAULT 0,
    base_id         BIGINT        NOT NULL DEFAULT 0,
    create_dept         BIGINT        NOT NULL DEFAULT 0,
    user_id         BIGINT        NOT NULL DEFAULT 0,
    PRIMARY KEY (machine_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_machine_info_machine_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_machine_info IS '机械信息表';
COMMENT ON COLUMN agriculture_machine_info.machine_id IS '机械ID';
COMMENT ON COLUMN agriculture_machine_info.machine_code IS '机械编码';
COMMENT ON COLUMN agriculture_machine_info.machine_name IS '机械名称';
COMMENT ON COLUMN agriculture_machine_info.machine_type_id IS '机械类别';
COMMENT ON COLUMN agriculture_machine_info.measure_unit IS '计量单位';
COMMENT ON COLUMN agriculture_machine_info.remark IS '备注';
COMMENT ON COLUMN agriculture_machine_info.status IS '状态';
COMMENT ON COLUMN agriculture_machine_info.order_num IS '排序';
COMMENT ON COLUMN agriculture_machine_info.create_by IS '创建者ID';
COMMENT ON COLUMN agriculture_machine_info.create_time IS '创建时间';
COMMENT ON COLUMN agriculture_machine_info.update_by IS '修改人ID';
COMMENT ON COLUMN agriculture_machine_info.update_time IS '修改时间';
COMMENT ON COLUMN agriculture_machine_info.del_flag IS '删除标志（0代表存在 2代表删除）';
COMMENT ON COLUMN agriculture_machine_info.tenant_id IS '租户ID';
COMMENT ON COLUMN agriculture_machine_info.base_id IS '基地ID';
COMMENT ON COLUMN agriculture_machine_info.create_dept IS '部门ID';
COMMENT ON COLUMN agriculture_machine_info.user_id IS '用户ID';


-- ----------------------------
-- Table structure for agriculture_machine_type
-- ----------------------------
DROP TABLE IF EXISTS agriculture_machine_type;

CREATE TABLE agriculture_machine_type
(
    machine_type_id   BIGINT        NOT NULL DEFAULT nextval('agriculture_machine_type_machine_type_id_seq'::regclass),
    machine_type_name VARCHAR(50)   NOT NULL DEFAULT '',
    remark            VARCHAR(2000) NOT NULL DEFAULT '',
    status            CHAR(1)       NOT NULL DEFAULT '0',
    order_num         INTEGER       NOT NULL DEFAULT 0,
    create_by         BIGINT        NOT NULL DEFAULT 0,
    create_time       TIMESTAMP,
    update_by         BIGINT                 DEFAULT 0,
    update_time       TIMESTAMP,
    del_flag          CHAR(1)       NOT NULL DEFAULT '0',
    tenant_id         BIGINT        NOT NULL DEFAULT 0,
    base_id           BIGINT        NOT NULL DEFAULT 0,
    create_dept           BIGINT        NOT NULL DEFAULT 0,
    user_id           BIGINT        NOT NULL DEFAULT 0,
    PRIMARY KEY (machine_type_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_machine_type_machine_type_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_machine_type IS '机械类别表';
COMMENT ON COLUMN agriculture_machine_type.machine_type_id IS '机械类别ID';
COMMENT ON COLUMN agriculture_machine_type.machine_type_name IS '机械类别名称';
COMMENT ON COLUMN agriculture_machine_type.remark IS '备注';
COMMENT ON COLUMN agriculture_machine_type.status IS '状态';
COMMENT ON COLUMN agriculture_machine_type.order_num IS '排序';
COMMENT ON COLUMN agriculture_machine_type.create_by IS '创建者ID';
COMMENT ON COLUMN agriculture_machine_type.create_time IS '创建时间';
COMMENT ON COLUMN agriculture_machine_type.update_by IS '修改人ID';
COMMENT ON COLUMN agriculture_machine_type.update_time IS '修改时间';
COMMENT ON COLUMN agriculture_machine_type.del_flag IS '删除标志（0代表存在 2代表删除）';
COMMENT ON COLUMN agriculture_machine_type.tenant_id IS '租户ID';
COMMENT ON COLUMN agriculture_machine_type.base_id IS '基地ID';
COMMENT ON COLUMN agriculture_machine_type.create_dept IS '部门ID';
COMMENT ON COLUMN agriculture_machine_type.user_id IS '用户ID';

-- 插入数据
BEGIN;
INSERT INTO agriculture_machine_type (machine_type_id, machine_type_name, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (1, '拖拉机', '2', '0', 3, 1, '2023-06-02 21:25:43', 1, '2023-06-13 09:29:33', '0', 0, 0, 0, 0);
INSERT INTO agriculture_machine_type (machine_type_id, machine_type_name, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (2, '收割机', '', '0', 4, 1, '2023-06-13 09:29:38', 1, '2024-05-07 11:42:59', '0', 0, 0, 0, 0);
INSERT INTO agriculture_machine_type (machine_type_id, machine_type_name, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (3, '插秧机', '', '0', 0, 9, '2023-06-13 09:29:43', 0, NULL, '0', 0, 0, 0, 0);
INSERT INTO agriculture_machine_type (machine_type_id, machine_type_name, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (4, '无人机', '', '0', 0, 9, '2023-08-26 13:41:04', 0, NULL, '0', 0, 0, 0, 0);
INSERT INTO agriculture_machine_type (machine_type_id, machine_type_name, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (5, '姚琼测试数据', '', '0', 0, 10, '2024-08-19 13:38:37', 0, NULL, '0', 113, 101, 103, 10);
INSERT INTO agriculture_machine_type (machine_type_id, machine_type_name, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (6, '拖拉机', '', '0', 0, 17, '2024-10-15 10:12:09', 0, NULL, '0', 113, 110, 110, 17);
COMMIT;


-- ----------------------------
-- Table structure for agriculture_material_info
-- ----------------------------
DROP TABLE IF EXISTS agriculture_material_info;

CREATE TABLE agriculture_material_info
(
    material_id      BIGINT        NOT NULL DEFAULT nextval('agriculture_material_info_material_id_seq'::regclass),
    material_code    VARCHAR(20)   NOT NULL DEFAULT '',
    material_name    VARCHAR(50)   NOT NULL DEFAULT '',
    material_type_id BIGINT        NOT NULL DEFAULT '0',
    measure_unit     VARCHAR(10)   NOT NULL DEFAULT '',
    remark           VARCHAR(2000) NOT NULL DEFAULT '',
    status           CHAR(1)       NOT NULL DEFAULT '0',
    order_num        INTEGER       NOT NULL DEFAULT 0,
    create_by        BIGINT        NOT NULL DEFAULT 0,
    create_time      TIMESTAMP,
    update_by        BIGINT                 DEFAULT 0,
    update_time      TIMESTAMP,
    del_flag         CHAR(1)       NOT NULL DEFAULT '0',
    tenant_id        BIGINT        NOT NULL DEFAULT 0,
    base_id          BIGINT        NOT NULL DEFAULT 0,
    create_dept          BIGINT        NOT NULL DEFAULT 0,
    user_id          BIGINT        NOT NULL DEFAULT 0,
    PRIMARY KEY (material_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_material_info_material_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_material_info IS '农资信息表';
COMMENT ON COLUMN agriculture_material_info.material_id IS '农资ID';
COMMENT ON COLUMN agriculture_material_info.material_code IS '农资编码';
COMMENT ON COLUMN agriculture_material_info.material_name IS '农资名称';
COMMENT ON COLUMN agriculture_material_info.material_type_id IS '农资类别';
COMMENT ON COLUMN agriculture_material_info.measure_unit IS '计量单位';
COMMENT ON COLUMN agriculture_material_info.remark IS '备注';
COMMENT ON COLUMN agriculture_material_info.status IS '状态';
COMMENT ON COLUMN agriculture_material_info.order_num IS '排序';
COMMENT ON COLUMN agriculture_material_info.create_by IS '创建者ID';
COMMENT ON COLUMN agriculture_material_info.create_time IS '创建时间';
COMMENT ON COLUMN agriculture_material_info.update_by IS '修改人ID';
COMMENT ON COLUMN agriculture_material_info.update_time IS '修改时间';
COMMENT ON COLUMN agriculture_material_info.del_flag IS '删除标志（0代表存在 2代表删除）';
COMMENT ON COLUMN agriculture_material_info.tenant_id IS '租户ID';
COMMENT ON COLUMN agriculture_material_info.base_id IS '基地ID';
COMMENT ON COLUMN agriculture_material_info.create_dept IS '部门ID';
COMMENT ON COLUMN agriculture_material_info.user_id IS '用户ID';


-- ----------------------------
-- Table structure for agriculture_material_type
-- ----------------------------
DROP TABLE IF EXISTS agriculture_material_type;

CREATE TABLE agriculture_material_type
(
    material_type_id   BIGINT        NOT NULL DEFAULT nextval('agriculture_material_type_material_type_id_seq'::regclass),
    material_type_name VARCHAR(50)   NOT NULL DEFAULT '',
    remark             VARCHAR(2000) NOT NULL DEFAULT '',
    status             CHAR(1)       NOT NULL DEFAULT '0',
    order_num          INTEGER       NOT NULL DEFAULT 0,
    create_by          BIGINT        NOT NULL DEFAULT 0,
    create_time        TIMESTAMP,
    update_by          BIGINT                 DEFAULT 0,
    update_time        TIMESTAMP,
    del_flag           CHAR(1)       NOT NULL DEFAULT '0',
    tenant_id          BIGINT        NOT NULL DEFAULT 0,
    base_id            BIGINT        NOT NULL DEFAULT 0,
    create_dept            BIGINT        NOT NULL DEFAULT 0,
    user_id            BIGINT        NOT NULL DEFAULT 0,
    PRIMARY KEY (material_type_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_material_type_material_type_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_material_type IS '农资类别表';
COMMENT ON COLUMN agriculture_material_type.material_type_id IS '农资类别ID';
COMMENT ON COLUMN agriculture_material_type.material_type_name IS '农资类别名称';
COMMENT ON COLUMN agriculture_material_type.remark IS '备注';
COMMENT ON COLUMN agriculture_material_type.status IS '状态';
COMMENT ON COLUMN agriculture_material_type.order_num IS '排序';
COMMENT ON COLUMN agriculture_material_type.create_by IS '创建者ID';
COMMENT ON COLUMN agriculture_material_type.create_time IS '创建时间';
COMMENT ON COLUMN agriculture_material_type.update_by IS '修改人ID';
COMMENT ON COLUMN agriculture_material_type.update_time IS '修改时间';
COMMENT ON COLUMN agriculture_material_type.del_flag IS '删除标志（0代表存在 2代表删除）';
COMMENT ON COLUMN agriculture_material_type.tenant_id IS '租户ID';
COMMENT ON COLUMN agriculture_material_type.base_id IS '基地ID';
COMMENT ON COLUMN agriculture_material_type.create_dept IS '部门ID';
COMMENT ON COLUMN agriculture_material_type.user_id IS '用户ID';

-- 插入数据
BEGIN;
INSERT INTO agriculture_material_type (material_type_id, material_type_name, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (1, '肥料', '', '0', 2, 1, '2023-06-13 09:40:21', 1, '2024-05-07 11:42:04', '0', 0, 0, 0, 0);
INSERT INTO agriculture_material_type (material_type_id, material_type_name, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (2, '镰刀', '', '0', 1, 9, '2023-06-13 09:40:46', 1, '2024-05-07 11:42:09', '0', 0, 0, 0, 0);
INSERT INTO agriculture_material_type (material_type_id, material_type_name, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (3, '姚琼测试类别', '', '0', 0, 10, '2024-08-19 11:43:33', 0, NULL, '0', 113, 101, 103, 10);
INSERT INTO agriculture_material_type (material_type_id, material_type_name, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag, tenant_id, base_id, create_dept, user_id) VALUES
    (4, '化肥', '', '0', 0, 17, '2024-10-15 10:12:50', 0, NULL, '0', 113, 110, 110, 17);
COMMIT;

-- ----------------------------
-- Table structure for agriculture_plant_method
-- ----------------------------
DROP TABLE IF EXISTS agriculture_plant_method;

CREATE TABLE agriculture_plant_method
(
    method_id    BIGINT        NOT NULL DEFAULT nextval('agriculture_plant_method_method_id_seq'::regclass),
    germplasm_id BIGINT        NOT NULL,
    method_name  VARCHAR(50)   NOT NULL DEFAULT '',
    method_img   VARCHAR(100)  NOT NULL DEFAULT '',
    method_des   VARCHAR(1000) NOT NULL DEFAULT '',
    remark       VARCHAR(2000) NOT NULL DEFAULT '',
    status       CHAR(1)       NOT NULL DEFAULT '0',
    order_num    INTEGER       NOT NULL DEFAULT 0,
    create_by    BIGINT        NOT NULL DEFAULT 0,
    create_time  TIMESTAMP,
    update_by    BIGINT                 DEFAULT 0,
    update_time  TIMESTAMP,
    del_flag     CHAR(1)       NOT NULL DEFAULT '0',
    PRIMARY KEY (method_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_plant_method_method_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_plant_method IS '种植方法表';
COMMENT ON COLUMN agriculture_plant_method.method_id IS '方法ID';
COMMENT ON COLUMN agriculture_plant_method.germplasm_id IS '种质ID';
COMMENT ON COLUMN agriculture_plant_method.method_name IS '名称';
COMMENT ON COLUMN agriculture_plant_method.method_img IS '图片';
COMMENT ON COLUMN agriculture_plant_method.method_des IS '描述';
COMMENT ON COLUMN agriculture_plant_method.remark IS '备注';
COMMENT ON COLUMN agriculture_plant_method.status IS '状态';
COMMENT ON COLUMN agriculture_plant_method.order_num IS '排序';
COMMENT ON COLUMN agriculture_plant_method.create_by IS '创建者ID';
COMMENT ON COLUMN agriculture_plant_method.create_time IS '创建时间';
COMMENT ON COLUMN agriculture_plant_method.update_by IS '修改人ID';
COMMENT ON COLUMN agriculture_plant_method.update_time IS '修改时间';
COMMENT ON COLUMN agriculture_plant_method.del_flag IS '删除标志（0代表存在 2代表删除）';

-- 插入数据
BEGIN;
INSERT INTO agriculture_plant_method (method_id, germplasm_id, method_name, method_img, method_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (1, 1, '方法2222', '/profile/iot/1/2023-0523-211723.png', '是的撒的撒的', '', '0', 0, 0, '2023-05-23 20:58:40', 0, '2023-05-24 13:55:47', '0');
INSERT INTO agriculture_plant_method (method_id, germplasm_id, method_name, method_img, method_des, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (2, 2, '方法', '/profile/iot/1/2023-0523-214207.png', '猜猜猜', '', '0', 0, 0, '2023-05-23 21:42:12', 0, '2023-05-24 13:55:34', '0');
COMMIT;


-- ----------------------------
-- Table structure for agriculture_standard_job
-- ----------------------------
DROP TABLE IF EXISTS agriculture_standard_job;

CREATE TABLE agriculture_standard_job
(
    job_id       BIGINT        NOT NULL DEFAULT nextval('agriculture_standard_job_job_id_seq'::regclass),
    germplasm_id BIGINT        NOT NULL DEFAULT 0,
    job_name     VARCHAR(50)   NOT NULL DEFAULT '',
    cycle_unit   CHAR(1)       NOT NULL DEFAULT '0',
    job_start    INTEGER       NOT NULL DEFAULT 0,
    job_finish   INTEGER       NOT NULL DEFAULT 0,
    remark       VARCHAR(2000) NOT NULL DEFAULT '',
    status       CHAR(1)       NOT NULL DEFAULT '0',
    order_num    INTEGER       NOT NULL DEFAULT 0,
    create_by    BIGINT        NOT NULL DEFAULT 0,
    create_time  TIMESTAMP,
    update_by    BIGINT                 DEFAULT 0,
    update_time  TIMESTAMP,
    del_flag     CHAR(1)       NOT NULL DEFAULT '0',
    PRIMARY KEY (job_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_standard_job_job_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_standard_job IS '标准作业任务表';
COMMENT ON COLUMN agriculture_standard_job.job_id IS '作业任务ID';
COMMENT ON COLUMN agriculture_standard_job.germplasm_id IS '种质ID';
COMMENT ON COLUMN agriculture_standard_job.job_name IS '作业任务名称';
COMMENT ON COLUMN agriculture_standard_job.cycle_unit IS '作业周期单位（0代表周 1代表天）';
COMMENT ON COLUMN agriculture_standard_job.job_start IS '起始周/天';
COMMENT ON COLUMN agriculture_standard_job.job_finish IS '结束周/天';
COMMENT ON COLUMN agriculture_standard_job.remark IS '备注';
COMMENT ON COLUMN agriculture_standard_job.status IS '状态';
COMMENT ON COLUMN agriculture_standard_job.order_num IS '排序';
COMMENT ON COLUMN agriculture_standard_job.create_by IS '创建者ID';
COMMENT ON COLUMN agriculture_standard_job.create_time IS '创建时间';
COMMENT ON COLUMN agriculture_standard_job.update_by IS '修改人ID';
COMMENT ON COLUMN agriculture_standard_job.update_time IS '修改时间';
COMMENT ON COLUMN agriculture_standard_job.del_flag IS '删除标志（0代表存在 2代表删除）';

-- 插入数据
BEGIN;
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (1, 2, '播种', '1', 1, 3, '', '0', 0, 1, '2023-05-25 22:15:16', 1, '2023-05-30 09:37:59', '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (2, 2, '浇水', '1', 2, 4, '', '0', 0, 1, '2023-05-30 09:38:25', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (3, 2, '采摘', '1', 5, 6, '', '0', 0, 1, '2023-05-30 09:38:47', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (4, 1, '育苗', '1', 1, 3, '', '0', 0, 1, '2023-05-30 17:40:31', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (5, 1, '铺膜', '1', 3, 4, '', '0', 0, 1, '2023-05-30 17:41:18', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (6, 1, '育苗完成', '1', 5, 6, '', '0', 0, 1, '2023-05-30 17:41:39', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (7, 1, '定植', '1', 6, 7, '', '0', 0, 1, '2023-05-30 17:41:56', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (8, 1, '植保防护', '1', 7, 8, '', '0', 0, 1, '2023-05-30 17:42:25', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (9, 1, '授粉', '1', 9, 10, '', '0', 0, 1, '2023-05-30 17:42:49', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (10, 1, '修剪侧蔓', '1', 11, 12, '', '0', 0, 1, '2023-05-30 17:45:54', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (11, 1, '坐果期', '1', 12, 13, '', '0', 0, 1, '2023-05-30 17:46:13', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (12, 1, '膨果期', '1', 13, 14, '', '0', 0, 1, '2023-05-30 17:46:37', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (13, 1, '结果期', '1', 14, 15, '', '0', 0, 1, '2023-05-30 17:46:52', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (14, 1, '采摘', '1', 15, 16, '', '0', 0, 1, '2023-05-30 17:47:29', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (15, 1, '作业流程', '0', 1, 2, '', '0', 0, 8, '2023-08-26 14:11:15', 0, NULL, '2');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (16, 3, '播种', '1', 1, 1, '', '0', 0, 1, '2023-09-05 12:53:54', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (17, 3, '收获', '1', 2, 2, '', '0', 0, 1, '2023-09-05 12:54:10', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (18, 1, '测试', '0', 30, 40, '', '0', 0, 1, '2024-03-15 14:19:42', 0, NULL, '2');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (19, 4, '播种', '1', 1, 3, '', '0', 0, 10, '2024-08-19 14:20:21', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (20, 4, '浇水', '1', 4, 5, '', '0', 0, 10, '2024-08-19 14:20:39', 9, '2024-09-18 11:42:48', '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (21, 5, '浇水', '0', 1, 5, '', '0', 0, 9, '2024-09-18 11:43:35', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (22, 5, '收获', '0', 6, 9, '', '0', 0, 9, '2024-09-18 11:43:47', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (23, 6, '育苗', '1', 1, 3, '', '0', 0, 17, '2024-09-26 14:37:34', 0, NULL, '0');
INSERT INTO agriculture_standard_job (job_id, germplasm_id, job_name, cycle_unit, job_start, job_finish, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (24, 6, '施肥', '1', 3, 4, '', '0', 0, 17, '2024-09-26 14:37:46', 0, NULL, '0');
COMMIT;


-- ----------------------------
-- Table structure for agriculture_task_employee
-- ----------------------------
DROP TABLE IF EXISTS agriculture_task_employee;

CREATE TABLE agriculture_task_employee
(
    id          BIGINT        NOT NULL DEFAULT nextval('agriculture_task_employee_id_seq'::regclass),
    task_id     BIGINT        NOT NULL DEFAULT 0,
    employee_id BIGINT        NOT NULL DEFAULT 0,
    remark      VARCHAR(2000) NOT NULL DEFAULT '',
    status      CHAR(1)       NOT NULL DEFAULT '0',
    order_num   INTEGER       NOT NULL DEFAULT 0,
    create_by   BIGINT        NOT NULL DEFAULT 0,
    create_time TIMESTAMP,
    update_by   BIGINT                 DEFAULT 0,
    update_time TIMESTAMP,
    del_flag    CHAR(1)       NOT NULL DEFAULT '0',
    PRIMARY KEY (id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_task_employee_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_task_employee IS '批次任务工人表';
COMMENT ON COLUMN agriculture_task_employee.id IS 'ID';
COMMENT ON COLUMN agriculture_task_employee.task_id IS '任务ID';
COMMENT ON COLUMN agriculture_task_employee.employee_id IS '雇员ID';
COMMENT ON COLUMN agriculture_task_employee.remark IS '备注';
COMMENT ON COLUMN agriculture_task_employee.status IS '状态';
COMMENT ON COLUMN agriculture_task_employee.order_num IS '排序';
COMMENT ON COLUMN agriculture_task_employee.create_by IS '创建者ID';
COMMENT ON COLUMN agriculture_task_employee.create_time IS '创建时间';
COMMENT ON COLUMN agriculture_task_employee.update_by IS '修改人ID';
COMMENT ON COLUMN agriculture_task_employee.update_time IS '修改时间';
COMMENT ON COLUMN agriculture_task_employee.del_flag IS '删除标志（0代表存在 2代表删除）';

-- 插入数据
BEGIN;
INSERT INTO agriculture_task_employee (id, task_id, employee_id, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (1, 1, 6, '', '0', 0, 17, '2024-09-26 14:50:54', 0, NULL, '2');
INSERT INTO agriculture_task_employee (id, task_id, employee_id, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (2, 1, 6, '', '0', 0, 17, '2024-09-26 14:54:38', 0, NULL, '0');
INSERT INTO agriculture_task_employee (id, task_id, employee_id, remark, status, order_num, create_by, create_time, update_by, update_time, del_flag) VALUES
    (3, 13, 5, '', '0', 0, 12, '2024-10-18 14:49:48', 0, NULL, '0');
COMMIT;


-- ----------------------------
-- Table structure for agriculture_task_log
-- ----------------------------
DROP TABLE IF EXISTS agriculture_task_log;

CREATE TABLE agriculture_task_log
(
    log_id      BIGINT        NOT NULL DEFAULT nextval('agriculture_task_log_log_id_seq'::regclass),
    task_id     BIGINT        NOT NULL DEFAULT 0,
    oper_name   VARCHAR(50)   NOT NULL DEFAULT '',
    oper_id     BIGINT        NOT NULL DEFAULT 0,
    oper_des    VARCHAR(500)  NOT NULL DEFAULT '',
    remark      VARCHAR(2000) NOT NULL DEFAULT '',
    status      CHAR(1)       NOT NULL DEFAULT '0',
    order_num   INTEGER       NOT NULL DEFAULT 0,
    create_by   BIGINT        NOT NULL DEFAULT 0,
    create_time TIMESTAMP,
    update_by   BIGINT                 DEFAULT 0,
    update_time TIMESTAMP,
    del_flag    CHAR(1)       NOT NULL DEFAULT '0',
    PRIMARY KEY (log_id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_task_log_log_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_task_log IS '批次任务日志表';
COMMENT ON COLUMN agriculture_task_log.log_id IS '日志ID';
COMMENT ON COLUMN agriculture_task_log.task_id IS '任务ID';
COMMENT ON COLUMN agriculture_task_log.oper_name IS '操作人名称';
COMMENT ON COLUMN agriculture_task_log.oper_id IS '操作人Id';
COMMENT ON COLUMN agriculture_task_log.oper_des IS '操作描述';
COMMENT ON COLUMN agriculture_task_log.remark IS '备注';
COMMENT ON COLUMN agriculture_task_log.status IS '状态';
COMMENT ON COLUMN agriculture_task_log.order_num IS '排序';
COMMENT ON COLUMN agriculture_task_log.create_by IS '创建者ID';
COMMENT ON COLUMN agriculture_task_log.create_time IS '创建时间';
COMMENT ON COLUMN agriculture_task_log.update_by IS '修改人ID';
COMMENT ON COLUMN agriculture_task_log.update_time IS '修改时间';
COMMENT ON COLUMN agriculture_task_log.del_flag IS '删除标志（0代表存在 2代表删除）';

-- ----------------------------
-- Table structure for agriculture_unit
-- ----------------------------
DROP TABLE IF EXISTS agriculture_unit;

CREATE TABLE agriculture_unit
(
    id         BIGINT NOT NULL DEFAULT nextval('agriculture_unit_id_seq'::regclass),
    land_id    BIGINT,
    type       INTEGER,
    element_id BIGINT,
    PRIMARY KEY (id)
);


-- 创建序列用于自动递增
CREATE SEQUENCE agriculture_unit_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

-- 添加注释
COMMENT ON TABLE agriculture_unit IS '种植单元';
COMMENT ON COLUMN agriculture_unit.id IS 'ID';
COMMENT ON COLUMN agriculture_unit.land_id IS '地块id';
COMMENT ON COLUMN agriculture_unit.type IS '单元要素类型：1设备 2监控 3种植批次 4自动化场景  其他类型可自由拓展';
COMMENT ON COLUMN agriculture_unit.element_id IS '要素id';

-- 插入数据
BEGIN;
INSERT INTO agriculture_unit (id, land_id, type, element_id) VALUES (80, 2, 2, 4);
INSERT INTO agriculture_unit (id, land_id, type, element_id) VALUES (81, 2, 3, 8);
INSERT INTO agriculture_unit (id, land_id, type, element_id) VALUES (84, 1, 1, 1);
INSERT INTO agriculture_unit (id, land_id, type, element_id) VALUES (85, 1, 1, 5);
INSERT INTO agriculture_unit (id, land_id, type, element_id) VALUES (86, 1, 3, 3);
COMMIT;
